1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| NSDictionary personData =[NSDictionary dictionaryWithObjectsAndKeys:@"Kevin", @"firstName",@"Jin", @"lastName",[NSNumber numberWithInt:25], @"age", nil];
NSDictionary personData = @{@"firstName" : @"Kevin",@"lastName" : @"Jin", @"age" : @25};
NSString str1; NSString str2 = @"1"; NSString str3 = @"1";
NSDictionary dic =@{@"str1":str1,@"str2":str2,@"str3":str3};
NSDictionary dic = [NSDictionary dictionaryWithObjectsAndKeys:str1,@"str2",str2,@"str2",str3,@"str3", nil]; NSLog(@"dic.count=%d",dic.count);
NSString lastName = [personData objectForKey:@"lastName"];
NSString lastName = personData[@"lastName"];
[mutableDictionary setObject:@"Galloway" forKey:@"lastName"];
mutableDictionary[@"lastName"] = @"Galloway";
|